package com.lrkj.lease.controller;

import com.lrkj.lease.domain.LeaseContract;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.lease.domain.ContractCategory;
import com.lrkj.lease.service.IContractCategoryService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 合同类型Controller
 *
 * @author yajun_ren
 * @date 2022-04-26
 */
@RestController
@RequestMapping("/lease/ContractCategory")
@Api(tags = "合同类型")
public class ContractCategoryController extends BaseController
{
    @Autowired
    private IContractCategoryService contractCategoryService;

    /**
     * 查询合同类型列表
     */
    @ApiOperation(value = "查询合同类型列表", notes = "查询合同类型列表")
    @PreAuthorize("@ss.hasPermi('lease:ContractCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(ContractCategory contractCategory)
    {
        startPage();
        this.changeParameter(contractCategory.getParams());
        List<ContractCategory> list = contractCategoryService.selectContractCategoryList(contractCategory);
        return getDataTable(list);
    }

    /**
     * 导出合同类型列表
     */
	@ApiOperation(value = "导出合同类型列表", notes = "导出合同类型列表")
    @PreAuthorize("@ss.hasPermi('lease:ContractCategory:export')")
    @Log(title = "合同类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ContractCategory contractCategory)
    {
        List<ContractCategory> list = contractCategoryService.selectContractCategoryList(contractCategory);
        ExcelUtil<ContractCategory> util = new ExcelUtil<ContractCategory>(ContractCategory.class);
        return util.exportExcel(list, "合同类型数据");
    }

    /**
     * 获取合同类型详细信息
     */
	@ApiOperation(value = "获取合同类型详细信息", notes = "获取合同类型详细信息")
    @PreAuthorize("@ss.hasPermi('lease:ContractCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(contractCategoryService.selectContractCategoryById(id));
    }

    /**
     * 新增合同类型
     */
    @ApiOperation(value = "新增合同类型", notes = "新增合同类型")
    @PreAuthorize("@ss.hasPermi('lease:ContractCategory:add')")
    @Log(title = "合同类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContractCategory contractCategory)
    {
        return toAjax(contractCategoryService.insertContractCategory(contractCategory));
    }

    /**
     * 修改合同类型
     */
    @ApiOperation(value = "修改合同类型", notes = "修改合同类型")
    @PreAuthorize("@ss.hasPermi('lease:ContractCategory:edit')")
    @Log(title = "合同类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContractCategory contractCategory)
    {
        return toAjax(contractCategoryService.updateContractCategory(contractCategory));
    }

    /**
     * 删除合同类型
     */
    @ApiOperation(value = "删除合同类型", notes = "删除合同类型")
    @PreAuthorize("@ss.hasPermi('lease:ContractCategory:remove')")
    @Log(title = "合同类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(contractCategoryService.deleteContractCategoryByIds(ids));
    }



}
